package com.ktjy.t382.ch01.controller;

import com.ktjy.t382.ch01.pojo.SysUser;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/test")
public class TestController {
    @ResponseBody
    @RequestMapping("/add")
    public SysUser add(@RequestBody SysUser sysUser) {
        System.out.println(sysUser);
        // 调用服务层方法添加用户，返回受影响的行数
//        int saveBatch = sysUserService.saveBatch(sysUser);
//        // 如果添加成功，重定向到用户列表页面
//        if (saveBatch > 0) {
//            return "redirect:/user/list";
//        } else {
//            // 否则重定向到错误页面
//            return "redirect:/error.jsp";
//        }
        return sysUser;
    }
}
